Thực đơn
Sắp xếp chèn Ví dụCho danh sách
1 | 3 | 7 | - | 6 | 4 | 2 | 5 |
Danh sách con gồm 3 phần tử bên trái 1,3,7 đã được sắp. Để tiếp tục sắp xếp phần tử thứ tư a 4 = 6 {\displaystyle a_{4}=6} vào danh sách con đó, ta tìm vị trí thích hợp của nó là sau 3 và trước 7.
1 | 3 | 6 | 7 | - | 4 | 2 | 5 |
Làm tiếp theo với a 5 = 4 {\displaystyle a_{5}=4} ta được
1 | 3 | 4 | 6 | 7 | - | 2 | 5 |
Làm tiếp theo với a 6 = 2 {\displaystyle a_{6}=2} ta được
1 | 2 | 3 | 4 | 6 | 7 | - | 5 |
Cuối cùng chèn a 7 = 5 {\displaystyle a_{7}=5}
1 | 2 | 3 | 4 | 5 | 6 | 7 | - |
Thực đơn
Sắp xếp chèn Ví dụLiên quan
Tài liệu tham khảo
WikiPedia: Sắp xếp chèn http://www.cs.ubc.ca/spider/harrison/Java/sorting-... http://coderaptors.com/?InsertionSort http://electrofriends.com/source-codes/software-pr... http://www.pathcom.com/~vadco/binary.html http://www.sorting-algorithms.com/insertion-sort http://citeseerx.ist.psu.edu/viewdoc/summary?doi=1... http://www.cs.sunysb.edu/~bender/newpub/BenderFaMo... http://www.algolist.net/Algorithms/Sorting/Inserti... http://dl.acm.org/citation.cfm?id=1132705 http://literateprograms.org/Category:Insertion_sor...